/*
 * @Author: Gigi 1517618446@qq.com
 * @Date: 2022-08-29 18:59:18
 * @LastEditors: Gigi 1517618446@qq.com
 * @LastEditTime: 2022-09-03 22:39:47
 * @FilePath: \ws\js\myOrder.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

noOrders();

//冒泡事件
var delliele;
document.querySelector(".tab-content").onclick = function(event){
    var ele = event.target;

     //点击删除按钮，先获取要删除的 li 元素，用于一会的确认删除操作
     if(ele.nodeName == "BUTTON" && ele.className == "del"){
        delliele = ele.parentElement.parentElement;
     }
 
     //确认删除操作
     else if(ele.nodeName == "BUTTON" && ele.className == "yes"){
         $("#myModal").modal("hide");
         delliele.remove();
         noOrders();
      }
}

//如果无订单，显示无订单提醒
function noOrders(){
    var eleArr = document.querySelectorAll(".myul");
    for(var i = 0; i < eleArr.length; i++){
          if(eleArr[i].innerText == '' || (eleArr[i].childNodes[0].nodeName == '#text' && eleArr[i].childNodes.length == 1))
          eleArr[i].innerHTML = '<div class="noOrder"><p class="words">没有订单哦~<br>快去首页逛逛吧！</p></div>';
        }
}